Re: create links based on attribute llandale - Fri Jun 14 17:32:26 EDT 2013
Your code looks good, one of these assumptions is wrong:
-
The "Sys Req Link ID" values are not always the same as the identifier of the 1st object in your CIDS module
-
At line #39 you don't have the link-creation commented out like you do right now.
-
"m" is always open "edit". It think your code should check for that.
-
The extra double quotes "" don't matter. [SysReqLinkId ""] should be the same as [SysReqLinkId]. You only need them to turn something that is not a string into a string; you don't need to use them after a string; Since I never do that I really don't know if it might be your problem. that is, I wonder if these two lines are equivalent:
-
if (!isDeleted(oCIDS) && identifier(oCIDS) "" == SysReqLinkId ""){
-
if (!isDeleted(oCIDS) && identifier(oCIDS) == SysReqLinkId){
or perhaps this is what it is doing:
-
if (!isDeleted(oCIDS) && identifier(oCIDS) ("" == SysReqLinkId "")){
-Louie
Seems to me you should check for the existence of the link before creating it. Also, for huge "current" modules and huge "CIDS" module you can drastically improve execution time by:
-
Skip skpCIDS = createString() // KEY 'string' identifier of cids object; DATA 'Object' handle.
-
for oCIDS in entire cidsMod do
-
{ if (!isDeleted(oCIDS)) then put (skpCIDS, identifier(oCIDS), oCIDS)
-
}
Get rid of you cidsMod loop at line #34, and do this
if (find(skpCIDS, SysReqLinkId, oCIDS)) then create the link else report not found.
|
Re: create links based on attribute bellincm - Mon Jun 17 13:11:26 EDT 2013 llandale - Fri Jun 14 17:32:26 EDT 2013
Your code looks good, one of these assumptions is wrong:
-
The "Sys Req Link ID" values are not always the same as the identifier of the 1st object in your CIDS module
-
At line #39 you don't have the link-creation commented out like you do right now.
-
"m" is always open "edit". It think your code should check for that.
-
The extra double quotes "" don't matter. [SysReqLinkId ""] should be the same as [SysReqLinkId]. You only need them to turn something that is not a string into a string; you don't need to use them after a string; Since I never do that I really don't know if it might be your problem. that is, I wonder if these two lines are equivalent:
-
if (!isDeleted(oCIDS) && identifier(oCIDS) "" == SysReqLinkId ""){
-
if (!isDeleted(oCIDS) && identifier(oCIDS) == SysReqLinkId){
or perhaps this is what it is doing:
-
if (!isDeleted(oCIDS) && identifier(oCIDS) ("" == SysReqLinkId "")){
-Louie
Seems to me you should check for the existence of the link before creating it. Also, for huge "current" modules and huge "CIDS" module you can drastically improve execution time by:
-
Skip skpCIDS = createString() // KEY 'string' identifier of cids object; DATA 'Object' handle.
-
for oCIDS in entire cidsMod do
-
{ if (!isDeleted(oCIDS)) then put (skpCIDS, identifier(oCIDS), oCIDS)
-
}
Get rid of you cidsMod loop at line #34, and do this
if (find(skpCIDS, SysReqLinkId, oCIDS)) then create the link else report not found.
So, I updated my code to have the skip list, but it's still only creating a link from the current module to the first object in the CIDS module. Any other ideas, also creating the skip list didn't free up time. In fact it extends it...
*************************************************************************
// This script can be executed from any module.
// All modules outlinks to/from this module need to be open.
Module m = current
string modName = m."Name"
Module cidsMod = read ("/Test/GCV IFV System Specification", true)
if (null cidsMod) {
errorBox "Unable to get read access to the GCV IFV System Specification.\n\n" //-
"This script requires that module to be opened in Read Only."
halt
}
Object o, oTgt, oSrc, oCIDS
string tempTarget, tgtName, tempSource, srcName,SysReqLinkId
Link lnk,newLnk
int inlinkCount = 0
int outlinkCount = 0
bool linkCreated
int linkCreatedCount = 0
print "Initiated " m."Name" " module link creation.\n\n"
for o in entire m do {
SysReqLinkId = o."Sys Req Link ID"
linkCreated = false
//print "Found link start - " identifier(o) "\n"
Skip skpCIDS = createString() // KEY 'string' identifier of cids object; DATA 'Object' handle.
for oCIDS in entire cidsMod do {
if (!isDeleted(oCIDS)) then put (skpCIDS,identifier(oCIDS),oCIDS){
if (find(skpCIDS, SysReqLinkId, oCIDS)){
newLink = o -> "/Test/System Links" -> oCIDS
linkCreated = true
//linkCreatedCount++
print "Link created from " identifier(o) " to "
print identifier(oCIDS) ".\n"
}
}
}
}
|
Re: create links based on attribute llandale - Tue Jun 18 12:56:57 EDT 2013 bellincm - Mon Jun 17 13:11:26 EDT 2013
So, I updated my code to have the skip list, but it's still only creating a link from the current module to the first object in the CIDS module. Any other ideas, also creating the skip list didn't free up time. In fact it extends it...
*************************************************************************
// This script can be executed from any module.
// All modules outlinks to/from this module need to be open.
Module m = current
string modName = m."Name"
Module cidsMod = read ("/Test/GCV IFV System Specification", true)
if (null cidsMod) {
errorBox "Unable to get read access to the GCV IFV System Specification.\n\n" //-
"This script requires that module to be opened in Read Only."
halt
}
Object o, oTgt, oSrc, oCIDS
string tempTarget, tgtName, tempSource, srcName,SysReqLinkId
Link lnk,newLnk
int inlinkCount = 0
int outlinkCount = 0
bool linkCreated
int linkCreatedCount = 0
print "Initiated " m."Name" " module link creation.\n\n"
for o in entire m do {
SysReqLinkId = o."Sys Req Link ID"
linkCreated = false
//print "Found link start - " identifier(o) "\n"
Skip skpCIDS = createString() // KEY 'string' identifier of cids object; DATA 'Object' handle.
for oCIDS in entire cidsMod do {
if (!isDeleted(oCIDS)) then put (skpCIDS,identifier(oCIDS),oCIDS){
if (find(skpCIDS, SysReqLinkId, oCIDS)){
newLink = o -> "/Test/System Links" -> oCIDS
linkCreated = true
//linkCreatedCount++
print "Link created from " identifier(o) " to "
print identifier(oCIDS) ".\n"
}
}
}
}
As for the "Skip"; the idea is to plow through all the CIDS objects only once and put them in the Skip. Do that after opening the CIDS module. Within the "for o in m do" loop, you need only try to "find" the object in the Skip; you do NOT want to plow through the objects again. Outline:
-
mCIDS = read(CIDS)
-
skpCIDS = createString
-
for o in entire mCIDS do {if not deleted put in skpCIDS}
-
..
-
for o in m do
-
{ if (find in skpCIDS) then ...
As for your problem, I think you should verify that my assumptions in my original post are correct; and I'm guessing you will find the 1st assumption is not the case. That is, "Sys Req Link ID" values for all "m" objects are the same ... and the same as the 1st object in the CIDS module. try this:
-
for o in (current Module) do {print identifier(o) "\t[" (o."Sys Req Link ID") "]\n"
-Louie
|